import MarkdownIt from 'markdown-it'
import '@/assets/markdown.css'

//代码高亮插件
import MarkdownItHighlight from '@/utils/markdown-it-plugins/highlight'

//latex公式
import MarkdownItTexmath from '@/utils/markdown-it-plugins/texmath'

const defaultOptions = {
  html: true,
}

export default (options = {}) => {
  options = Object.assign(defaultOptions, options)
  const md = MarkdownIt(options)

  if (typeof MarkdownItTexmath !== 'undefined') {
    MarkdownItTexmath(md)
  }
  if (typeof MarkdownItHighlight !== 'undefined') {
    MarkdownItHighlight(md)
  }

  return md
}
